<?php

namespace App\Http\Controllers\Wechat\Shop;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Repos\OrderProductRepo;
use App\Repos\ShopVisitorRepo;
use App\Http\Requests\Api\Shop\ProductRequest;

class CountController extends Controller
{
    public function index(ProductRequest $request)
    {
    	$rs['status']     = true;
       

        $where['shop_id'] = $request->shopUser->shop_id;
        // 最近七天访问量
        $rs['data']['visitor'] = ShopVisitorRepo::countByDate($where);
        $trade = OrderProductRepo::countByOrder($where);
        $rs['data']['trade'] = $trade;
        if($request->day) {
            $where['day'] = $request->day;
        }
        // 昨日订单统计
        //dd($where);
        $list = OrderProductRepo::countByProduct($where);

        $rs['data']['order']['list'] = $list;
        return response()->json($rs)->setEncodingOptions(JSON_NUMERIC_CHECK);;  
    }

   
}
